#ifndef UNDOMANAGER_H
#define UNDOMANAGER_H

#include "appGlobals.h"
#include <QUndoStack>

class UndoManager : public QObject
{
	Q_OBJECT
public:
	struct UndoData
	{
		QAction* pUndoAct;
		QAction* pRedoAct;
		QUndoStack undoStack;
	};
	typedef QMap<QPointer<QObject>, UndoData*> UndoMap;

	UndoManager(QObject *parent);
	~UndoManager();

	QPointer<QObject> currentUndoObject() const;

	QAction* currentUndoAction();
	QAction* currentRedoAction();
	QUndoStack& currentUndoStack();
private:
	UndoMap m_undoMap;
	QPointer<QObject> m_currentUndoObject;
signals:
	void currentUndoObjectChanged(QObject* pObject);
public slots:
	void addUndoableObject(QObject* pObject);
	void removeUndoableObject(QObject* pObject);
	void setCurrentUndoObject(QObject* pObject);
};

#endif // UNDOMANAGER_H
